﻿<UserControl x:Class="CAION2.Controls.EnchantStigmaPlace"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:CAION2.Controls"
             xmlns:viewModels="clr-namespace:CAION2.ViewModels"
             x:Name="Control"
             Width="42"
             Height="42"
             Background="Transparent"
             IsEnabled="{Binding IsEnabled}"
             ToolTipService.ShowDuration="36000">

    <UserControl.Resources>

        <viewModels:IconConverter x:Key="IconConverter"/>
        <viewModels:ItemTypeColorConverter x:Key="ItemTypeColorConverter"/>
        <viewModels:StigmaToolTipConverter x:Key="StigmaToolTipConverter"/>
        <viewModels:TextLenghtToVisibleConverter x:Key="TextLenghtToVisibleConverter"/>

    </UserControl.Resources>

    <UserControl.DataContext>
        <viewModels:StigmaPlaceViewModel />
    </UserControl.DataContext>

    <UserControl.Style>
        <Style TargetType="{x:Type controls:EnchantStigmaPlace}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderBrush" Value="{DynamicResource Accent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>

    <UserControl.ToolTip>
        <Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="45"/>
                    <ColumnDefinition MaxWidth="405"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50"/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Image Source="{Binding CurrentStigmaRow[skillicon_name], Converter={StaticResource IconConverter}}"
                        Width="40"
                        Height="40"
                        VerticalAlignment="Top"
                        Stretch="Uniform"
                        Margin="0,0,5,0"/>

                <TextBlock Grid.Row="0" 
                            Grid.Column="1"
                            Text="{Binding CurrentStigmaRow[translate]}"
                           Foreground="{Binding CurrentStigmaRow[quality], Converter={StaticResource ItemTypeColorConverter}}"
                           
                            TextWrapping="Wrap"
                            VerticalAlignment="Top"/>

                <TextBlock Grid.Row="0" 
                            Grid.Column="1"
                            FontSize="10"
                            Margin="0,0,0,10"
                            Text="{Binding CurrentStigmaRow[level], Converter={StaticResource StigmaToolTipConverter}, ConverterParameter=Level}"
                            TextWrapping="Wrap"
                            VerticalAlignment="Bottom"/>

                <TextBlock Grid.Column="1"
                            Grid.Row="1"
                            Text="{Binding CurrentStigmaRow[desc_long]}"
                            TextWrapping="Wrap"
                            MaxWidth="400"
                           Margin="0,0,5,0"
                            VerticalAlignment="Center"/>

                <TextBlock Grid.Column="1"
                            Grid.Row="2"
                            Margin="0,10,0,0"
                            TextWrapping="Wrap"
                            VerticalAlignment="Center"
                            Text="{Binding CurrentStigmaRow.ItemArray, Converter={StaticResource StigmaToolTipConverter}, ConverterParameter=Enhanted}"/>

                <StackPanel Grid.Column="1"
                            Grid.Row="3"
                            Margin="0,10,0,0"
                            Orientation="Horizontal">

                    <Image Source="/CAION2;component/UI2/CrystalShard.png"
                            Width="16"
                            Height="16"
                            VerticalAlignment="Center"
                            Margin="0,0,5,0"/>

                    <TextBlock Text="{Binding CurrentStigmaRow[require_shard], StringFormat={}{0:N0}}"
                                TextWrapping="Wrap"
                                VerticalAlignment="Center"/>

                    <Image Source="/CAION2;component/UI2/AbyssPoints.png"
                            Width="16"
                            Height="16"
                            Visibility="{Binding CurrentStigmaRow[abyss_point], Converter={StaticResource TextLenghtToVisibleConverter},
                                                        FallbackValue=Visibility.Collapsed}"
                            VerticalAlignment="Center"
                            Margin="20,0,5,0"/>

                    <TextBlock Text="{Binding CurrentStigmaRow[abyss_point], StringFormat={}{0:N0}, ConverterCulture=Ru-ru}"
                                TextWrapping="Wrap"
                                VerticalAlignment="Center"/>

                </StackPanel>

            </Grid>
        </Grid>
    </UserControl.ToolTip>


    <Canvas Width="{Binding Width, ElementName=Control}"
            Height="{Binding Height, ElementName=Control}"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">

        <Image Width="40"
               Height="40"
               Margin="2,2,0,0"
               Panel.ZIndex="1"
               Source="{Binding Icon,
                                Mode=OneWay,
                                UpdateSourceTrigger=PropertyChanged}"
               Stretch="Uniform" />

        <Border Width="39"
                Height="39"
                Margin="3,3,0,0"
                Panel.ZIndex="4"
                Background="{Binding RedBackground,
                                     Mode=OneWay,
                                     UpdateSourceTrigger=PropertyChanged}"/>

        <Border Width="42"
                Height="42"
                Panel.ZIndex="7"
                BorderBrush="{Binding BorderBrush,
                                          ElementName=Control,
                                          Mode=OneWay}"
                BorderThickness="2" />

    </Canvas>

</UserControl>
